<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

/**
 * Class ExcelFile
 *
 * @property int $id
 * @property int|null $operation_id
 * @property string|null $order_status
 * @property Carbon|null $start_time
 * @property Carbon|null $end_time
 * @property int|null $branch_id
 * @property int|null $time_chose
 * @property int|null $file_type
 * @property int|null $user_id
 * @property int|null $worker_id
 * @property int|null $product_id
 * @property int|null $is_success
 * @property Carbon|null $create_time
 * @property Carbon|null $update_time
 * @property string|null $file_url
 * @property string|null $file_path
 *
 * @property Branch|null $branch
 * @property Worker|null $worker
 * @property Product|null $product
 * @property User|null $user
 *
 * @package App\Models
 */
class ExcelFile extends Model
{
	protected $table = 'excel_files';

	protected $casts = [
		'operation_id' => 'int',
		'branch_id' => 'int',
		'time_chose' => 'int',
		'file_type' => 'int',
		'user_id' => 'int',
		'worker_id' => 'int',
		'product_id' => 'int',
		'is_success' => 'int'
	];

	protected $dates = [
		'start_time',
		'end_time'
	];

	protected $fillable = [
		'operation_id',
		'order_status',
		'start_time',
		'end_time',
		'branch_id',
		'time_chose',
		'file_type',
		'user_id',
		'worker_id',
		'product_id',
		'is_success',
		'file_url',
		'file_path'
	];

    public function branch()
    {
        return $this->belongsTo(Branch::class);
    }

    public function worker()
    {
        return $this->belongsTo(Worker::class, 'worker_id');
    }

    public function operation()
    {
        return $this->belongsTo(Worker::class, 'operation_id');
    }

    public function product()
    {
        return $this->belongsTo(Product::class);
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }
}
